<?php
function message($msg)
{
	header('Content-type: text/html; charset=utf-8');
	echo $msg;
	exit;
}
$id = empty($_GET['id']) ? 0 : intval($_GET['id']);
$sn = empty($_GET['sn']) ? 0 : intval($_GET['sn']);
$type = empty($_GET['type']) ? "up" : trim($_GET['type']);

header('location:index.php?app=default&act=down&id=' . $id);

//
//if(empty($sn))
//{
//header('location:index.php?app=default&act=down&id=' . $id);
//}
//
//define('ROOT_PATH', dirname(__FILE__));
//define('CHARSET', 'utf-8');
//
//$conf = include_once(ROOT_PATH . '/data/config.inc.php');
//
//foreach ($conf as $key => $value) {
//	define($key, $value);
//}
//include_once(ROOT_PATH . '/eccore/ecmall.php');
//include_once(ROOT_PATH . '/eccore/model/model.base.php');
//
//
//
//if (!$id) {
//	message('文件不存在！');
//}
//
//
//$filename="";
//$filepath="";
//
//if($type=="up")
//{
//	$upload_mod =& m('upload');
//	$file = $upload_mod->get_info($id);
//	if (!$file) {
//		message('文件不存在！');
//	}
//	$filename = $file['file_name'];
//	$filepath = $file['file_path'];
//}
//elseif($type=="cc")
//{
//	$colorcard_mode=&m('color_card');
//    $info = $colorcard_mode->get_info($id);
//	if (!$info) {
//		message('文件不存在！');
//	}
//	$filename = basename($info['picture']);
//	$filepath = $info['picture'];
//}
//elseif($type=="fab")
//{
//		$fabric_info_mod =& m('fabric_info');
//		$info = $fabric_info_mod->get('fabric_info_id = ' . $id);
//
//		if (!$info) {
//		message('文件不存在！');
//		}
//	  $filename = basename($info['picture']);
//	  $filepath = $info['picture'];
//
//}
//else
//{
//	message('文件不存在！');
//}
////echo $filepath;
////exit();
//if (!file_exists($filepath)) {
//	message('文件不存在！');
//}
//$filesize = filesize($filepath);
//
//header("Content-type: application/octet-stream; charset=utf-8"); 
//header("Accept-Ranges: bytes"); 
//header("Accept-Length: " . $filesize); 
//header("Content-Length: " . $filesize);
//if(strpos($_SERVER["HTTP_USER_AGENT"],"MSIE")) {
//	header("Content-Disposition: attachment; filename=\"" . rawurlencode($filename) . '"'); 
//} else {
//	header("Content-Disposition: attachment; filename=\"" . $filename . '"'); 
//}
//$file = fopen($filepath, 'r');
//echo fread($file, $filesize);
//fclose($file);
//exit;
?>